package com.ubxtech.rabbitmq.listener;

import com.ubxtech.rabbitmq.bo.RabbitmqEventBO;
import com.ubxtech.rabbitmq.service.RabbitmqService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import jakarta.annotation.Resource;

/**
 * @author Victor.Xiao
 * @since 2023-05-30 11:18
 **/
@Component
@Slf4j
public class RabbitmqListener {

    @Resource
    private RabbitmqService rabbitmqService;

    @EventListener
    public void handleEvent(RabbitmqEventBO event) {

        if (log.isDebugEnabled()) {
            log.debug("监听到发送rabbitmq事件 handleEvent:{}", event);
        }
        rabbitmqService.convertAndSend(event);
    }
}
